package com.wondersgroup.core.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wondersgroup.core.mapper.AppVersionMapper;
import com.wondersgroup.core.resultmap.DTOAppVersion;
import com.wondersgroup.core.util.QueryResult;

@Service
public class AppVersionService {
	
	@Autowired
	private AppVersionMapper appVersionMapper;
	public QueryResult<DTOAppVersion> searchApplicationVersion(String appType, 
			int appStatus, String versionName, 
			String description,Date startDate, Date endDate, int pageNo, int pageSize){
		PageHelper.startPage(pageNo, pageSize);
		List<DTOAppVersion> list=appVersionMapper.queryAppVersionList(appType, appStatus, versionName, description, startDate, endDate);
		PageInfo<DTOAppVersion> page = new PageInfo<DTOAppVersion>(list);
		QueryResult<DTOAppVersion> result=new QueryResult<>();
		result.setResultList(list);
		result.setCurrPageNo(pageNo);
		result.setPageCount((long)page.getPages());
		result.setTotalRecord(page.getTotal());
		result.setPageSize(pageSize);
		return result;
	}
}
